package com.cppsu.cgx.libraryseatselection.mapper;

import static com.cppsu.cgx.libraryseatselection.mapper.TipOffsDynamicSqlSupport.*;
import static org.mybatis.dynamic.sql.SqlBuilder.*;

import com.cppsu.cgx.libraryseatselection.entity.TipOffs;
import java.util.List;
import java.util.Optional;
import javax.annotation.Generated;
import org.apache.ibatis.annotations.DeleteProvider;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.SelectKey;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.type.JdbcType;
import org.mybatis.dynamic.sql.BasicColumn;
import org.mybatis.dynamic.sql.delete.DeleteDSLCompleter;
import org.mybatis.dynamic.sql.delete.render.DeleteStatementProvider;
import org.mybatis.dynamic.sql.insert.render.InsertStatementProvider;
import org.mybatis.dynamic.sql.select.CountDSLCompleter;
import org.mybatis.dynamic.sql.select.SelectDSLCompleter;
import org.mybatis.dynamic.sql.select.render.SelectStatementProvider;
import org.mybatis.dynamic.sql.update.UpdateDSL;
import org.mybatis.dynamic.sql.update.UpdateDSLCompleter;
import org.mybatis.dynamic.sql.update.UpdateModel;
import org.mybatis.dynamic.sql.update.render.UpdateStatementProvider;
import org.mybatis.dynamic.sql.util.SqlProviderAdapter;
import org.mybatis.dynamic.sql.util.mybatis3.MyBatis3Utils;

@Mapper
public interface TipOffsMapper {
    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    BasicColumn[] selectList = BasicColumn.columnList(id, userId, createTime, note, handleStatus, repay, handleTime, seatId, position, seatNumber);

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    @SelectProvider(type=SqlProviderAdapter.class, method="select")
    long count(SelectStatementProvider selectStatement);

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    @DeleteProvider(type=SqlProviderAdapter.class, method="delete")
    int delete(DeleteStatementProvider deleteStatement);

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    @InsertProvider(type=SqlProviderAdapter.class, method="insert")
    @SelectKey(statement="SELECT LAST_INSERT_ID()", keyProperty="record.id", before=false, resultType=Long.class)
    int insert(InsertStatementProvider<TipOffs> insertStatement);

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    @SelectProvider(type=SqlProviderAdapter.class, method="select")
    @ResultMap("TipOffsResult")
    Optional<TipOffs> selectOne(SelectStatementProvider selectStatement);

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    @SelectProvider(type=SqlProviderAdapter.class, method="select")
    @Results(id="TipOffsResult", value = {
        @Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true),
        @Result(column="user_id", property="userId", jdbcType=JdbcType.BIGINT),
        @Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="note", property="note", jdbcType=JdbcType.VARCHAR),
        @Result(column="handle_status", property="handleStatus", jdbcType=JdbcType.INTEGER),
        @Result(column="repay", property="repay", jdbcType=JdbcType.VARCHAR),
        @Result(column="handle_time", property="handleTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="seat_id", property="seatId", jdbcType=JdbcType.BIGINT),
        @Result(column="position", property="position", jdbcType=JdbcType.VARCHAR),
        @Result(column="seat_number", property="seatNumber", jdbcType=JdbcType.VARCHAR)
    })
    List<TipOffs> selectMany(SelectStatementProvider selectStatement);

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    @UpdateProvider(type=SqlProviderAdapter.class, method="update")
    int update(UpdateStatementProvider updateStatement);

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default long count(CountDSLCompleter completer) {
        return MyBatis3Utils.countFrom(this::count, tipOffs, completer);
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default int delete(DeleteDSLCompleter completer) {
        return MyBatis3Utils.deleteFrom(this::delete, tipOffs, completer);
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default int deleteByPrimaryKey(Long id_) {
        return delete(c -> 
            c.where(id, isEqualTo(id_))
        );
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default int insert(TipOffs record) {
        return MyBatis3Utils.insert(this::insert, record, tipOffs, c ->
            c.map(userId).toProperty("userId")
            .map(createTime).toProperty("createTime")
            .map(note).toProperty("note")
            .map(handleStatus).toProperty("handleStatus")
            .map(repay).toProperty("repay")
            .map(handleTime).toProperty("handleTime")
            .map(seatId).toProperty("seatId")
            .map(position).toProperty("position")
            .map(seatNumber).toProperty("seatNumber")
        );
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default int insertSelective(TipOffs record) {
        return MyBatis3Utils.insert(this::insert, record, tipOffs, c ->
            c.map(userId).toPropertyWhenPresent("userId", record::getUserId)
            .map(createTime).toPropertyWhenPresent("createTime", record::getCreateTime)
            .map(note).toPropertyWhenPresent("note", record::getNote)
            .map(handleStatus).toPropertyWhenPresent("handleStatus", record::getHandleStatus)
            .map(repay).toPropertyWhenPresent("repay", record::getRepay)
            .map(handleTime).toPropertyWhenPresent("handleTime", record::getHandleTime)
            .map(seatId).toPropertyWhenPresent("seatId", record::getSeatId)
            .map(position).toPropertyWhenPresent("position", record::getPosition)
            .map(seatNumber).toPropertyWhenPresent("seatNumber", record::getSeatNumber)
        );
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default Optional<TipOffs> selectOne(SelectDSLCompleter completer) {
        return MyBatis3Utils.selectOne(this::selectOne, selectList, tipOffs, completer);
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default List<TipOffs> select(SelectDSLCompleter completer) {
        return MyBatis3Utils.selectList(this::selectMany, selectList, tipOffs, completer);
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default List<TipOffs> selectDistinct(SelectDSLCompleter completer) {
        return MyBatis3Utils.selectDistinct(this::selectMany, selectList, tipOffs, completer);
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default Optional<TipOffs> selectByPrimaryKey(Long id_) {
        return selectOne(c ->
            c.where(id, isEqualTo(id_))
        );
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default int update(UpdateDSLCompleter completer) {
        return MyBatis3Utils.update(this::update, tipOffs, completer);
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    static UpdateDSL<UpdateModel> updateAllColumns(TipOffs record, UpdateDSL<UpdateModel> dsl) {
        return dsl.set(userId).equalTo(record::getUserId)
                .set(createTime).equalTo(record::getCreateTime)
                .set(note).equalTo(record::getNote)
                .set(handleStatus).equalTo(record::getHandleStatus)
                .set(repay).equalTo(record::getRepay)
                .set(handleTime).equalTo(record::getHandleTime)
                .set(seatId).equalTo(record::getSeatId)
                .set(position).equalTo(record::getPosition)
                .set(seatNumber).equalTo(record::getSeatNumber);
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    static UpdateDSL<UpdateModel> updateSelectiveColumns(TipOffs record, UpdateDSL<UpdateModel> dsl) {
        return dsl.set(userId).equalToWhenPresent(record::getUserId)
                .set(createTime).equalToWhenPresent(record::getCreateTime)
                .set(note).equalToWhenPresent(record::getNote)
                .set(handleStatus).equalToWhenPresent(record::getHandleStatus)
                .set(repay).equalToWhenPresent(record::getRepay)
                .set(handleTime).equalToWhenPresent(record::getHandleTime)
                .set(seatId).equalToWhenPresent(record::getSeatId)
                .set(position).equalToWhenPresent(record::getPosition)
                .set(seatNumber).equalToWhenPresent(record::getSeatNumber);
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default int updateByPrimaryKey(TipOffs record) {
        return update(c ->
            c.set(userId).equalTo(record::getUserId)
            .set(createTime).equalTo(record::getCreateTime)
            .set(note).equalTo(record::getNote)
            .set(handleStatus).equalTo(record::getHandleStatus)
            .set(repay).equalTo(record::getRepay)
            .set(handleTime).equalTo(record::getHandleTime)
            .set(seatId).equalTo(record::getSeatId)
            .set(position).equalTo(record::getPosition)
            .set(seatNumber).equalTo(record::getSeatNumber)
            .where(id, isEqualTo(record::getId))
        );
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default int updateByPrimaryKeySelective(TipOffs record) {
        return update(c ->
            c.set(userId).equalToWhenPresent(record::getUserId)
            .set(createTime).equalToWhenPresent(record::getCreateTime)
            .set(note).equalToWhenPresent(record::getNote)
            .set(handleStatus).equalToWhenPresent(record::getHandleStatus)
            .set(repay).equalToWhenPresent(record::getRepay)
            .set(handleTime).equalToWhenPresent(record::getHandleTime)
            .set(seatId).equalToWhenPresent(record::getSeatId)
            .set(position).equalToWhenPresent(record::getPosition)
            .set(seatNumber).equalToWhenPresent(record::getSeatNumber)
            .where(id, isEqualTo(record::getId))
        );
    }
}